package kr.or.kosta.otr.persistence.score;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.annotation.Resource;

import kr.or.kosta.otr.vo.ScoreVO;

import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
@Repository("ScoreDao")
public class ScoreDaoImpl implements ScoreDao {
	@Resource(name="sqlMapClient")
	private SqlMapClient sqlMapClient;
	
	@Override
	public void writeScore(ScoreVO scoreVo) throws SQLException {
		sqlMapClient.insert("Score.writeScore",scoreVo);
	}

	@Override
	public void deleteScore(int scoreId) throws SQLException {
		sqlMapClient.delete("Score.deleteScore",scoreId);
	}

	@Override
	public ScoreVO getAllScore(int scoreId) throws SQLException {
		return (ScoreVO) sqlMapClient.queryForObject("Score.getAllScore",scoreId);
	}

	@Override
	public ArrayList<Integer> getAllCompanyOrderByPromotion()
			throws SQLException {
		return (ArrayList<Integer>) sqlMapClient.queryForList("Score.getAllCompanyOrderByPromotion");
	}

	@Override
	public ArrayList<Integer> getAllCompanyOrderByWelfare() throws SQLException {
		return (ArrayList<Integer>) sqlMapClient.queryForList("Score.getAllCompanyOrderByWelfare");
	}

	@Override
	public ArrayList<Integer> getAllCompanyOrderByCulture() throws SQLException {
		return (ArrayList<Integer>) sqlMapClient.queryForList("Score.getAllCompanyOrderByCulture");
	}

	@Override
	public ArrayList<Integer> getAllCompanyOrderByHoliday() throws SQLException {
		return (ArrayList<Integer>) sqlMapClient.queryForList("Score.getAllCompanyOrderByHoliday");
	}

	@Override
	public ArrayList<Integer> getAllCompanyOrderByExecutive()
			throws SQLException {
		return (ArrayList<Integer>) sqlMapClient.queryForList("Score.getAllCompanyOrderByExecutive");
	}

	@Override
	public ArrayList<Integer> getAllCompanyOrderByOverdue() throws SQLException {
		return (ArrayList<Integer>) sqlMapClient.queryForList("Score.getAllCompanyOrderByOverdue");
	}

	@Override
	public float getCompanyScoreTotal(int companyId) throws SQLException {
		
		return (float) sqlMapClient.queryForObject("Score.getCompanyScoreTotal",companyId);
	}

	@Override
	public void updateTotalScore(int scoreId) throws SQLException {
		sqlMapClient.update("Score.updateTotalScore", scoreId);
		
	}

	@Override
	public float getTotalScoreOfChance(int companyId) throws SQLException {
		
		return (float) sqlMapClient.queryForObject("Score.getTotalScoreOfChance",companyId);
	}

	@Override
	public float getTotalScoreOfWelfare(int companyId) throws SQLException {
		return (float) sqlMapClient.queryForObject("Score.getTotalScoreOfWelfare",companyId);
	}

	@Override
	public float getTotalScoreOfCulture(int companyId) throws SQLException {
		return (float) sqlMapClient.queryForObject("Score.getTotalScoreOfCulture",companyId);
	}

	@Override
	public float getTotalScoreOfHoliday(int companyId) throws SQLException {
		return (float) sqlMapClient.queryForObject("Score.getTotalScoreOfHoliday",companyId);
	}

	@Override
	public float getTotalScoreOfExecutive(int companyId) throws SQLException {
		return (float) sqlMapClient.queryForObject("Score.getTotalScoreOfExecutive",companyId);
	}

	@Override
	public float getTotalScoreOfOverdue(int companyId) throws SQLException {
		return (float) sqlMapClient.queryForObject("Score.getTotalScoreOfOverdue",companyId);
	}

	@Override
	public float getTotalScoreOfTotal(int companyId) throws SQLException {
		
		return (float) sqlMapClient.queryForObject("Score.getTotalScoreOfTotal",companyId);
	}

}
